//
//  ChangePhoneVC.m
//  hnGovernment
//
//  Created by 安仔 on 17/3/6.
//  Copyright © 2017年 安仔. All rights reserved.
//

#import "ChangePhoneVC.h"
#import "RegisterView.h"
#import "FinishChangePhoneVC.h"
#import "DDbaseNetWork+Login.h"
#import "DDcacheManager.h"

@interface ChangePhoneVC ()<RegisterViewDelegate>

@property (nonatomic, strong) RegisterView *changePhoneView;
@end

@implementation ChangePhoneVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = NSLocalString(@"修改手机号");
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.changePhoneView = [[RegisterView alloc] initWithFrame:CGRectMake(0, -88 * m6Scale, KScreenWidth, KScreenHeight - 98 * m6Scale)];
    self.changePhoneView.signImg.hidden = YES;
    self.changePhoneView.titleLab.hidden = NO;
    self.changePhoneView.pactLab.hidden = YES;
    self.changePhoneView.isResetMobile = YES;
    self.changePhoneView.delegate = self;
    [self.view addSubview:self.changePhoneView];
    [self.changePhoneView.nextBtn mas_updateConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view.mas_centerX);
        make.top.mas_equalTo(self.changePhoneView.checkTF.mas_bottom).offset(64 * m6Scale);
        make.size.mas_equalTo(CGSizeMake(600 * m6Scale, 80 * m6Scale));
        
    }];
    
}

- (void)clickConfirmatBtn {


}

- (void)clickNextBtn {
    
    ZWUserModel *model = [cacheManager getUserModel];
    [DDNetWorkManager saveRebindNewMobile:self.changePhoneView.phoneTF.text oldMobile:model.mobile token:[cacheManager userToken] smsCode:self.changePhoneView.checkTF.text controller:self success:^(id result, DDcacheType cacheType, DDresultType resultType) {
        [DDHudHelper showHudWithResult:result resultSuccess:^{
            model.mobile = self.changePhoneView.phoneTF.text;
            [cacheManager cacheUserInfoWithModel:model];
            FinishChangePhoneVC *vc = [[FinishChangePhoneVC alloc] init];
            [self.navigationController pushViewController:vc animated:YES];
        }];
    } error:^(NSError *error) {
    }];
}

- (void)RegisterViewClickConfirmatBtn {
    NSLog(@"confirm");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
